package com.books.service.shoppingcar.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.books.mapper.shoppingcar.ShoppingCarMapper;
import com.books.model.entity.shopping.ShoppingCar;
import com.books.service.shoppingcar.IShoppingCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author ZhouRui
 * @title: 码上就来
 * @projectName cbstore-spring-boot
 * @description: TODO
 * @date 2021/10/510:31
 */

@Service
@Transactional
public class ShoppingCarServiceImpl implements IShoppingCarService {
    @Autowired(required = false)
    private ShoppingCarMapper shoppingCarMapper;

    @Autowired(required = false)
    private QueryWrapper<ShoppingCar> queryWrapper;

    @Override
    public ShoppingCar findById(int id) {
        return shoppingCarMapper.selectById(id);
    }

    @Override
    public List<ShoppingCar> findAllByUid(int uid) {
        return shoppingCarMapper.findAll(uid);
    }

    @Override
    public void addCar(ShoppingCar shoppingCar) {

        shoppingCarMapper.insert(shoppingCar);
    }

    @Override
    public int delCarById(int id) {

        return shoppingCarMapper.deleteById(id);
    }

    @Override
    public void updataCar(ShoppingCar shoppingCar) {
        shoppingCarMapper.updateById(shoppingCar);
    }

    @Override
    public ShoppingCar getByBid(Integer id) {
        return shoppingCarMapper.getByBid(id);
    }
}
